package com.miraclengine.eventobject;

import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.ButtonSprite;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

public class EventButtonSprite extends ButtonSprite {
	
	private Scene scene;

	public EventButtonSprite(float pX, float pY, ITextureRegion pNormalTextureRegion, ITextureRegion pPressedTextureRegion, VertexBufferObjectManager pVertexBufferObjectManager, Scene scene, OnClickListener listener) {
		super(pX, pY, pNormalTextureRegion, pPressedTextureRegion,
				pVertexBufferObjectManager, listener);
		// TODO Auto-generated constructor stub
		this.scene = scene;
	}

	@Override
	public void setVisible(boolean pVisible) {
		// TODO Auto-generated method stub
		super.setVisible(pVisible);
		
		if(pVisible)
			this.scene.registerTouchArea(this);
		else 
			this.scene.unregisterTouchArea(this);
	}
}
